// $Id: gtkui.h 52 2007-05-30 16:34:55Z DarkAn9el $
/***************************************************************************
 *   Copyright (C) 2007 by Andrea Blankenstijn, Ulrich Giraud              *
 *   <darkan9el@gmail.com>, <blade.124@laposte.net>                        *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/

#ifndef GTKUI_H_
#define GTKUI_H_

/**
 * \class GtkUi gtkui.h
 * \brief Cette classe contiens la définition de la gui GTK--
 * Le contruscteur de la classe permets d'initialiser la GUI
 * et un simple appel de Gtk::Main::Run permets d'executer la GUI
 */
class GtkUi : public Gtk::Window {
  public:
    GtkUi(); /**< Constructeur de la classe*/

  private:
    void CreateKbd();     /**< Crée le pavé numérique */
    void CreateFnct();    /**< Crée les boutons de fonctions */
    void ArrangeBoxes();  /**< Range les boites ;) */
    void SetProperties(); /**< Définis le propriétés par défaut */
    void ExecCalc();      /**< Envoie le calcul dans cin et appelle les fct de main.cpp */

    std::map<std::string,Gtk::Button*>Functions; /**< Cette map contiens tous les boutons de fonctions */

    Gtk::Entry calc_entry;       /**< La Gtk::Entry principale */
    Gtk::Frame frame_kbd;        /**< Entoure le pavé numérique */
    Gtk::Table num_kbd,fnct_tbl; /**< Permettent de ranger les boutons */
    Gtk::VBox main_box;          /**< la VBox mère en quelque sorte */
    Gtk::Button *nums_buttons[10],*pi,*point,*div,*mul,*min,*plus;

  protected:
    virtual void KeyboardButtonClicked(int number);   /**< Fonction callback pour le clavier numérique */
    virtual void ConnectWithText(Glib::ustring text); /**< Fonction callback pour les boutons avec texte */
};

#ifndef MAIN_H
#define MAIN_H
  #include <string>
  double error(const std::string& s);
  double expr(bool get);
  double ReadTable( std::string table_to_read );
  void SetDisplayMode(unsigned short mode);
  enum Token_value {
    KEY, NAME, NUMBER, END, PLUS='+',
    MINUS='-', MUL='*', DIV='/',
    PRINT=';', ASSIGN='=', LP='(', RP=')', EXP='^'
  };
  Token_value get_token();
#endif

#endif /*GTKUI_H_*/
